<?php

namespace App\Admin\Controllers;

use App\Jobs\SyncOneProductToES;
use App\Models\Agreement;
use App\Models\CollPosition;
use App\Models\Product;
use App\Models\ProductAttrKey;
use App\Models\ProductCategory;
use Encore\Admin\Controllers\AdminController;
use App\Admin\Actions\Post\Restore;
use App\Admin\Actions\Post\productSKUList;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;


class AgreementController extends AdminController
{
    protected $title = '协议列表';
    protected static $baseImg = 'https://liande.oss-cn-beijing.aliyuncs.com';

    protected function grid()
    {
        $grid = new Grid(new Agreement());

        $grid->column('id', __('Id号'));
        $grid->column('type', __('类型'));
        $grid->column('title', __('名称'));

        $grid->disableColumnSelector();
        $grid->disableFilter();
        $grid->disableExport();
        $grid->disableRowSelector();
        $grid->disableColumnSelector();

        return $grid;
    }

    protected function detail($id)
    {
        $show = new Show(Agreement::findOrFail($id));

//        $show->field('id', __('Id号'));
        $show->field('type', __('类型'));
        $show->field('title', __('名称'));

        $show->panel()
            ->tools(function ($tools) {
//                $tools->disableDelete();
            });

        return $show;
    }

    protected function form()
    {
        $form = new Form(new Agreement());

        $form->text('type', __('类型'))->required();
        $form->text('title', __('名称'))->required();
        $form->UEditor('content', '内容')->options(['initialFrameHeight' => 800]);

        return $form;
    }
}